home *** CD-ROM | disk | FTP | other *** search
- class Sounds
- {
- static var mainSounds;
- static var mcSoundsHolder;
- static var soundsList;
- static var randomSoundNamesList;
- static var ambienceInterval;
- function Sounds()
- {
- }
- static function setSounds(Void)
- {
- if(Sounds.mainSounds == undefined)
- {
- Sounds.mainSounds = new Sound(_root);
- Sounds.mcSoundsHolder = _root.createEmptyMovieClip("mcSoundsHolder",_root.getNextHighestDepth());
- Sounds.init();
- Sounds.mainSoundUp();
- Sounds.playSound("gameMusic",99999);
- Sounds.setVolume("gameMusic",70);
- }
- }
- static function mainSoundUp(Void)
- {
- _root.mcSoundBtn.gotoAndStop("up");
- _root.mcSoundBtn.btnSound.onRelease = Sounds.mainSoundMedium;
- Sounds.mainSounds.setVolume(100);
- Sounds.playSound("gameMusic",99999);
- }
- static function mainSoundMedium(Void)
- {
- _root.mcSoundBtn.gotoAndStop("medium");
- _root.mcSoundBtn.btnSound.onRelease = Sounds.mainSoundDown;
- Sounds.stopSound("gameMusic");
- }
- static function mainSoundDown(Void)
- {
- _root.mcSoundBtn.gotoAndStop("down");
- _root.mcSoundBtn.btnSound.onRelease = Sounds.mainSoundUp;
- Sounds.mainSounds.setVolume(0);
- }
- static function init(Void)
- {
- var _loc4_ = new Array("skid","vapourise","tyrescreech","carCrash","gameMusic","splash","engineIdle");
- Sounds.soundsList = new Object();
- var _loc5_ = _loc4_.length;
- var _loc1_ = 0;
- while(_loc1_ < _loc5_)
- {
- var _loc2_ = _loc4_[_loc1_];
- var _loc3_ = Sounds.mcSoundsHolder.createEmptyMovieClip("holder" + _loc1_,_loc1_);
- Sounds.soundsList[_loc2_] = new Sound(_loc3_);
- Sounds.soundsList[_loc2_].attachSound(_loc2_);
- _loc1_ = _loc1_ + 1;
- }
- Sounds.setVolume("splash",250);
- Sounds.setVolume("engineIdle",250);
- }
- static function playSound(name, loops)
- {
- if(loops == undefined)
- {
- loops = 0;
- }
- Sounds.soundsList[name].start(0,loops);
- }
- static function stopSound(name)
- {
- Sounds.soundsList[name].stop();
- }
- static function stopAllSounds(Void)
- {
- for(var _loc1_ in Sounds.soundsList)
- {
- }
- }
- static function setVolume(name, volume)
- {
- Sounds.soundsList[name].setVolume(volume);
- }
- static function getVolume(name)
- {
- return Sounds.soundsList[name].getVolume();
- }
- static function playAmbience(Void)
- {
- var _loc2_ = Sounds.randomSoundNamesList.length;
- var _loc3_ = Math.floor(_loc2_ * Math.random());
- var _loc1_ = Sounds.randomSoundNamesList[_loc3_];
- var _loc4_ = 20 + Math.floor(30 * Math.random());
- Sounds.setVolume(_loc1_,_loc4_);
- Sounds.playSound(_loc1_,0);
- Sounds.stopAmbience();
- Sounds.startAmbience();
- }
- static function startAmbience(bFirst)
- {
- var _loc1_ = undefined;
- if(bFirst)
- {
- _loc1_ = 2000 + Math.round(3000 * Math.random());
- }
- else
- {
- _loc1_ = 10000 + Math.round(10000 * Math.random());
- }
- Sounds.ambienceInterval = setInterval(Sounds.playAmbience,_loc1_);
- }
- static function stopAmbience()
- {
- clearInterval(Sounds.ambienceInterval);
- }
- }
-